package com.example.studywords.sql;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import com.example.studywords.bean.TranslateBean;
import com.example.studywords.bean.WordBean;
import com.example.studywords.bean.WordInfoBean;
import com.example.studywords.bean.WordTransRelationBean;

@Database(entities = {TranslateBean.class, WordBean.class, WordInfoBean.class, WordTransRelationBean.class},
version = 1)
public abstract class MyDatabase extends RoomDatabase {
    private static MyDatabase myDatabase;
    public abstract TranslateDao translateDao();
    public abstract WordDao wordDao();
    public abstract WordInfoDao wordInfoDao();
    public abstract WordTransRelationDao wordTransRelationDao();

    public static MyDatabase getDatabase(Context context){
        if(myDatabase == null){
            myDatabase = Room.databaseBuilder(context.getApplicationContext(),MyDatabase.class,"word_study_database")
                    .build();
        }
        return myDatabase;
    }
}
